package com.ygqh.baby.model;

import com.ygqh.baby.ao.BargainGenerationMode;
import com.ygqh.baby.ao.JobStatus;
import com.ygqh.baby.po.YgUserBargainDetail;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 剁手页
 *
 * @author (作者)
 * @version V1.0
 * @ClassName: UserBargainInfo
 * @date 2017年8月18日 下午1:38:56
 */
public class UserBargainInfo {

    private Long userBargainId;

    private Long userId;

    private Long bargainId;

    private Long productId;

    private String productName;

    private BargainGenerationMode generationMode;

    private Boolean cutOnlyNew;
    private String imagePath;
    private String nickName;
    private String headImageUrl;

    private BigDecimal productPrice;

    private BigDecimal targetPrice;

    private BigDecimal cutPrice;

    private Date finishTime;

    private JobStatus bargainStatus;

    private String platformNo;

    private Boolean hasCut = false;// 是否砍过

    private Long orderId;

    private List<YgUserBargainDetail> cutList;


    /**
     * 砍价百分比
     */
    public int getCutPre() {
        BigDecimal divide = cutPrice.divide(productPrice.subtract(targetPrice), 2).multiply(new BigDecimal("100.00"));
        return divide.intValue();

    }

    public BargainGenerationMode getGenerationMode() {
        return generationMode;
    }

    public void setGenerationMode(BargainGenerationMode generationMode) {
        this.generationMode = generationMode;
    }

    public String getPlatformNo() {
        return platformNo;
    }

    public void setPlatformNo(String platformNo) {
        this.platformNo = platformNo;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getHeadImageUrl() {
        return headImageUrl;
    }

    public void setHeadImageUrl(String headImageUrl) {
        this.headImageUrl = headImageUrl;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Boolean getHasCut() {
        return hasCut;
    }

    public void setHasCut(Boolean hasCut) {
        this.hasCut = hasCut;
    }

    public Long getUserBargainId() {
        return userBargainId;
    }

    public void setUserBargainId(Long userBargainId) {
        this.userBargainId = userBargainId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public BigDecimal getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(BigDecimal productPrice) {
        this.productPrice = productPrice;
    }

    public BigDecimal getTargetPrice() {
        return targetPrice;
    }

    public void setTargetPrice(BigDecimal targetPrice) {
        this.targetPrice = targetPrice;
    }

    public BigDecimal getCutPrice() {
        return cutPrice;
    }

    public void setCutPrice(BigDecimal cutPrice) {
        this.cutPrice = cutPrice;
    }

    public Date getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }

    public String getBargainStatusStr() {
        if (bargainStatus.equals(JobStatus.Complete)) {
            return "已完成";
        }
        return bargainStatus.getTitle();
    }

    public JobStatus getBargainStatus() {
        if (this.bargainStatus.equals(JobStatus.Running) && System.currentTimeMillis() > finishTime.getTime()) {
            this.bargainStatus = JobStatus.Finish;
        }
        return bargainStatus;
    }

    public void setBargainStatus(JobStatus bargainStatus) {
        this.bargainStatus = bargainStatus;
    }

    public List<YgUserBargainDetail> getCutList() {
        return cutList;
    }

    public void setCutList(List<YgUserBargainDetail> cutList) {
        this.cutList = cutList;
    }

    public Long getBargainId() {
        return bargainId;
    }

    public void setBargainId(Long bargainId) {
        this.bargainId = bargainId;
    }

    public Date getCurrentDate() {
        return new Date();
    }

    public Boolean getCutOnlyNew() {
        return cutOnlyNew;
    }

    public void setCutOnlyNew(Boolean cutOnlyNew) {
        this.cutOnlyNew = cutOnlyNew;
    }

    @Override
    public String toString() {
        return "UserBargainInfo [userBargainId=" + userBargainId + ", userId=" + userId + ", bargainId=" + bargainId + ", productId=" + productId
                + ", productName=" + productName + ", imagePath=" + imagePath + ", productPrice=" + productPrice + ", targetPrice=" + targetPrice
                + ", cutPrice=" + cutPrice + ", finishTime=" + finishTime + ", bargainStatus=" + bargainStatus + ", cutList=" + cutList + "]";
    }

}
